package com.yeyks.common.em.pay;

/**
 * @Author fuchangshuai
 * @date 2019/3/7 6:39 PM
 */
public enum PayTypeEnum {

    WXPAY(0, "wxpay"),
    ALIPAY(1, "alipay"),
    UNITE(2, "unite"),
    JSAPI(3, "jsapi"),
    XCX(4, "xcx"),
    GZH(5, "gzh"),
    WALLET(6, "wallet"),
    MWEB(7, "MWEB");

    int value;
    String desc;

    PayTypeEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer value() {
        return this.value;
    }

    public String desc() {
        return this.desc;
    }

    public static String getDesc(int value) {
        PayTypeEnum[] payTypeEnums = values();
        for (PayTypeEnum payTypeEnum : payTypeEnums) {
            if (payTypeEnum.value() == value) {
                return payTypeEnum.desc();
            }
        }
        return null;
    }

    public static Integer getValue(String desc) {
        PayTypeEnum[] payTypeEnums = values();
        for (PayTypeEnum payTypeEnum : payTypeEnums) {
            if (payTypeEnum.desc().equals(desc)) {
                return payTypeEnum.value();
            }
        }
        return null;
    }

    public static PayTypeEnum getEnumFromDesc(String desc) {
        PayTypeEnum[] payTypeEnums = values();
        for (PayTypeEnum payTypeEnum : payTypeEnums) {
            if (payTypeEnum.desc().equals(desc)) {
                return payTypeEnum;
            }
        }
        return null;
    }

}
